/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.vinisoft.gymwebapp.model.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author vinikike
 */
@Entity
@Table(name = "gym_usuario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GymUsuario.findAll", query = "SELECT g FROM GymUsuario g"),
    @NamedQuery(name = "GymUsuario.findById", query = "SELECT g FROM GymUsuario g WHERE g.id = :id"),
    @NamedQuery(name = "GymUsuario.findByPassw", query = "SELECT g FROM GymUsuario g WHERE g.passw = :passw")})
public class GymUsuario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "id", nullable = false, length = 100)
    private String id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "passw", nullable = false, length = 100)
    private String passw;
    @JoinColumn(name = "id_rol", referencedColumnName = "id")
    @ManyToOne
    private GymRol idRol;
    @JoinColumn(name = "id_compania", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private GymCompania idCompania;

    public GymUsuario() {
    }

    public GymUsuario(String id) {
        this.id = id;
    }

    public GymUsuario(String id, String passw) {
        this.id = id;
        this.passw = passw;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPassw() {
        return passw;
    }

    public void setPassw(String passw) {
        this.passw = passw;
    }

    public GymRol getIdRol() {
        return idRol;
    }

    public void setIdRol(GymRol idRol) {
        this.idRol = idRol;
    }

    public GymCompania getIdCompania() {
        return idCompania;
    }

    public void setIdCompania(GymCompania idCompania) {
        this.idCompania = idCompania;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GymUsuario)) {
            return false;
        }
        GymUsuario other = (GymUsuario) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.vinisoft.gymwebapp.model.entities.GymUsuario[ id=" + id + " ]";
    }
    
}
